﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views {
    import flash.events.*;
    import flash.display.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.vo.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.views.components.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.utils.*;

    public class PlaceHolderViewMediator extends Mediator {

		[Inject]
        public var placeholderView:PlaceHolderView;
		[Inject]
        public var roomSlotsModel:RoomSlotsModel;
		[Inject]
        public var sessionModel:SessionModel;

        override public function onRegister():void{
            eventMap.mapListener(eventDispatcher, CustomizeEvent.ITEM_CLICKED, this.onItemClicked);
            eventMap.mapListener(eventDispatcher, EventConstants.REMOVE_SNAPAREAS, this.onRemoveSnapareas);
            eventMap.mapListener(this.placeholderView, EventConstants.SNAP_IN, this.onSnapInRoom);
            eventMap.mapListener(this.placeholderView, EventConstants.SNAP_OUT, dispatch);
        }
        private function onSnapInRoom(_arg1:SnapEvent):void{
            dispatch(_arg1.clone());
        }
        private function onItemClicked(_arg1:CustomizeEvent):void{
            switch (_arg1.destination){
                case ShopItemVO.DESTINATION_ROOM:
                    this.addRoomSnapareas();
                    break;
                default:
                    l("e Unknown destination:", _arg1.destination);
            };
        }
        private function addRoomSnapareas():void{
            this.placeholderView.cleanup();
            var _local1:MovieClip = AssetsLibrary.getMovieClip("SlotSelection");
            this.placeholderView.showRoomSnapareas(_local1, this.roomSlotsModel.getNextFreeSlots());
        }
        private function onRemoveSnapareas(_arg1:Event):void{
            this.placeholderView.cleanup();
        }

    }
}//package net.wooga.pets.views 
